package com.credithc.customers.manager.controller;

import com.credithc.baseserv.core.codes.CoreCodes;
import com.credithc.baseserv.core.message.Message;
import com.credithc.baseserv.core.message.MessageFactory;
import com.credithc.baseserv.pageHelper.PageInfo;
import com.credithc.customers.manager.ro.BizModifyRo;
import com.credithc.customers.manager.ro.CustomerAbnormalRo;
import com.credithc.customers.manager.service.IBizMonitorService;
import com.credithc.customers.manager.vo.BizModifyVo;
import com.credithc.customers.manager.vo.CustomerAbnormalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.HashMap;
import java.util.Map;

/**
 * @Title:
 * @Author: Denghx
 * @Date: 2018/12/18 17:41
 * @Description: com.credithc.customers.manager.controller
 * @Version: V1.0.0
 */
@RestController
@RequestMapping("/manager/yzt/v1")
public class BizMonitorController {
    @Autowired
    MessageFactory messageFactory;
    @Autowired
    IBizMonitorService bizMonitorService;

    /**
     * @description: 业务变更处理展示
     * @author: denghx
     * @date: 2018/12/20 19:11
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/bizModify")
    public Message getBizModify(@PathParam("customerNo") String customerNo, @PathParam("customerName") String customerName, @PathParam("subSystemSign") String subSystemSign, @PathParam("idCardNo") String idCardNo, @PathParam("status") String status, @PathParam("noticeStatus") String noticeStatus, @PathParam("createTimeStart") String createTimeStart, @PathParam("createTimeEnd") String createTimeEnd, @PathParam("updateTimeStart") String updateTimeStart, @PathParam("updateTimeEnd") String updateTimeEnd, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {
        BizModifyRo ro = new BizModifyRo();
        ro.setCustomerNo(customerNo);
        ro.setCustomerName(customerName);
        ro.setSubSystemSign(subSystemSign);
        ro.setIdCardNo(idCardNo);
        ro.setStatus(status);
        ro.setNoticeStatus(noticeStatus);
        ro.setCreateTimeStart(createTimeStart);
        ro.setCreateTimeEnd(createTimeEnd);
        ro.setUpdateTimeStart(updateTimeStart);
        ro.setUpdateTimeEnd(updateTimeEnd);
        ro.setPageNo(pageNo);
        ro.setPageSize(pageSize);
        PageInfo<BizModifyVo> list = bizMonitorService.getBizInfo(ro);
        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("pageInfo", list);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, pageInfo);

    }

    /**
     * @param customerName
     * @param idCardType
     * @param idCardNo
     * @param status
     * @param createTimeStart
     * @param createTimeEnd
     * @param pageNo
     * @param pageSize
     * @description: 异常信息列表展示
     * @author: denghx
     * @date: 2018/12/20 19:10
     * @param: customerNo
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/abnormal")
    public Message getAbnormalInfo(@PathParam("abnormalType") String abnormalType, @PathParam("customerName") String customerName, @PathParam("idCardType") String idCardType, @PathParam("idCardNo") String idCardNo, @PathParam("status") String status, @PathParam("createTimeStart") String createTimeStart, @PathParam("createTimeEnd") String createTimeEnd, @RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {
        CustomerAbnormalRo ro = new CustomerAbnormalRo();
        ro.setAbnormalType(abnormalType);
        ro.setCustomerName(customerName);
        ro.setIdCardNo(idCardNo);
        ro.setStatus(status);
        ro.setIdCardtype(idCardType);
        ro.setCreateTimeStart(createTimeStart);
        ro.setCreateTimeEnd(createTimeEnd);
        ro.setPageNo(pageNo);
        ro.setPageSize(pageSize);
        PageInfo<CustomerAbnormalVo> list = bizMonitorService.selectCustomerAbnormal(ro);
        Map<String, Object> pageInfo = new HashMap<>();
        pageInfo.put("pageInfo", list);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, pageInfo);

    }

    /**
     * @description: 异常信息管理详情
     * @author: denghx
     * @date: 2018/12/20 19:10
     * @param: id
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/abnormal/detail")
    public Message getAbnormalDetail(@PathParam("id") String id) {
        Map<String, Object> map = bizMonitorService.getAbnormalDetail(id);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, map);
    }

    /**
     * @description: 获取异常信息合并信息
     * @author: denghx
     * @date: 2019/1/19 11:09
     * @param: id
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/abnormal/mergeInfo")
    public Message getAbnormalMergeInfo(@PathParam("id") String id) {
        Map<String, Object> map = bizMonitorService.updateAbnormalInfo(id);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, map);
    }

    /**
     * @param status
     * @description: 异常信息管理状态变更
     * @author: denghx
     * @date: 2018/12/20 19:09
     * @param: id
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/abnormal/updateSts")
    public Message updateAbnormalSts(@PathParam("id") String id, @PathParam("status") Integer status) {
        bizMonitorService.updateAbnormalSts(id, status);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS);
    }

    /**
     * @description: 业务变更处理展示
     * @author: denghx
     * @date: 2018/12/22 21:01
     * @param: id
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/bizModify/updateBiz")
    public Message updateBiz(@PathParam("id") String id) {
        Map<String, Object> map = bizMonitorService.updateBiz(id);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, map);
    }

    /**
     * @description: 业务变更处理修改及通知
     * @author: denghx
     * @date: 2018/12/22 21:01
     * @param: id
     * @return: com.credithc.baseserv.core.message.Message
     */
    @GetMapping("/bizModify/updateSts")
    public Message updateSts(@PathParam("id") String id, @PathParam("customerName") String customerName, @PathParam("idCardType") String idCardType, @PathParam("idCardNo") String idCardNo, @PathParam("bizId") String bizId, @PathParam("customerNo") String customerNo) {
        int res = bizMonitorService.updateBizModify(bizId, id, customerName, idCardType, idCardNo, customerNo);
        return messageFactory.getInstance(CoreCodes.CORE_SUCCESS, res);
    }
}
